<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html>
<head>
	<title>机构(部门)用户列表</title>
	<%@ include file="/common/meta.jsp" %>
    <%@ include file="/common/import.jsp" %>
	<%@ include file="uct-import.jsp" %>
	
	<script>
		//var actsAry = "${acts}";//权限
		var utitle = '用户列表';
		var orgId = '${org.orgId}';
		if($.trim(orgId).length != 0){
			utitle = '[<font color="red">${org.orgCname}</font>]用户列表';
		}
	
		$(function(){
			$('#userList').datagrid({
				title:utitle,
				iconCls:'icon-ok',
				url:'${ctx}/uct/user/user!data.action?orgId='+orgId,
				nowrap: false,
				striped: true,
				collapsible:false,			
				fitColumns: true,
				pagination:true,
				singleSelect:true,
				rownumbers:true,
				remoteSort: false,
				pageList:[10,15,50],
				idField:'userId',
				columns:[[
					{field:'userEname',title:'账号',width:100,sortable:true,
						sorter:function(a,b){
							return (a>b?1:-1);
						}
					},
					{field:'userCname',title:'姓名',width:100,sortable:true,
						sorter:function(a,b){
							return (a>b?1:-1);
						}
					},
					{field:'orgEname',title:'所属机构',width:100,sortable:true,
						sorter:function(a,b){
							return (a>b?1:-1);
						}
					},
					{field:'userType',title:'用户类型',width:100,sortable:true,
						sorter:function(a,b){
							return (a>b?1:-1);
						}
						,
						formatter:function(value){
							if( value=='1'){return '交易会员';}
							else if(value=='2'){ return '业务人员';}
							else{return '';}
						}
					
					},
					{field:'userSex',title:'性别',width:100,
						formatter:function(value){
							if( value=='0'){return '女';}else{ return '男';}
						}
					},
					{field:'phone',title:'电话',width:100},
					{field:'userStatus',title:'状态',width:100,
						formatter:function(value){
							if( value=='1'){return '<font color=blue>启用</font>';}
							else{ return '<font color=red>停用</font>';}
						}
					}
				]]
			});
			
			 $('#userList').datagrid('getPanel').panel({
					onExpand: function(){
							$('#userActWin').panel('close');
					}
			});

			var p = $('#userList').datagrid('getPager');
			if (p){
				$(p).pagination({
					onBeforeRefresh:function(){
					}
				});
			}
		});
		
		$(function(){
			$('#userActWin').panel({
		  		onClose:function(){
		  			$('#userList').datagrid('getPanel').panel('expand');//
		  		},
		  		onExpand:function(){
		  			$('#userList').datagrid('getPanel').panel('collapse');
		  		},
		  		onCollapse:function(){
		  			$('#userList').datagrid('getPanel').panel('expand');
		  		}
			});
		});
		
			
		function reload(){
			$('#userList').datagrid('reload');
		}
		
		//新的查询功能
		function searchUserNew(){					
	    	var queryParams = $('#userList').datagrid('options').queryParams;	       
	        //queryParams.page = "1";
	        queryParams.userEname = $('#userEname').val();
	        queryParams.userCname = $('#userCname').val();
	        var options = $('#userList').datagrid('getPager').data("pagination").options;  
	        options.pageNumber=1;  
	        options.total=0;  
	        options.pageSize=10; 
	        $('#userList').datagrid("reload");
		   
		  }
		function clearSearch(){					
		    $('#userEname').val('');
		    $('#userCname').val('');
		     $('#userId').val('');
		 }  

		function getSelected(){
			var selected = $('#userList').datagrid('getSelected');
			if (selected){
				return selected;
			}else{
				$.messager.alert('提示', '请选择要操作的数据', 'info');
			}
		}

		function closeUserAdd(){
			$('#userAddWin').window('close');
		}
		
	</script>
</head>
<body>
		<table class="planel-body">
			<tr>
				<td>用户账号</td>
				<td>
					<input id="userEname" name="userEname" value=""/>
				</td>
				<td>用户姓名</td>
				<td>
					<input id="userCname" name="userCname" value=""/>
				</td>
				
				<td>
					<a class="easyui-linkbutton" iconCls="icon-search"
						onclick="searchUserNew();">查询</a>
					<a class="easyui-linkbutton" iconCls="" onclick="clearSearch();">清空</a>
				</td>
			</tr>
		</table>
	<table id="userList"></table>

	<!-- -->
	<div id="userActWin" class="easyui-panel" title="用户权限" icon="icon-lock" collapsible="false"  closed="true"
	closable="true" style="padding:5px;background:#fafafa;height:500px;"  >
   	 <iframe  frameborder="0"  id="userActFrame" height="100%" width="100%" scrolling="No" frameborder="0" ></iframe>
	
	</div>
	
	<div id="userAddWin" class="easyui-window" title="用户信息" style="padding:5px;width: 500px;height:420;"
    	iconCls="icon-search" closed="true" maximizable="false" minimizable="false" collapsible="false">
   	 <iframe  frameborder="0"  id="userAddFrame" height="100%" width="100%" scrolling="No" frameborder="0" ></iframe>
    </div>
    
	
</body>
</html>